ArcDir
The dopus version command can be used to check that your script will only
run on specific versions of Opus.
More ARexx functions have been added since Opus v5 was first created, if
you create a script that uses commands that are in Opus Magellan but not
in Opus v5.5, you can use dopus version to ensure that the script will
only run on Opus Magellan or later.
The result is returned as two numbers representing the version and the
revision, separated by a space.
Example:
/* DOpusVersion.dopus5 */
options results
address 'DOPUS.1'
dopus version /* Ask for version information */
text = 'Your DOpus version is: 'result /* Format result into string */
dopus request '"'text'" OK' /* Output to a requester */
dopus version
newopus = result ~= 'RESULT' & translate(result,'.',' ') ~<5.1215
if newopus then text = 'You can use the ''lister request'' command.'
else text = 'You can''t use the ''lister request'' command.'
dopus request '"'text'" OK'
exit
In the example above, we reduced the version information to a boolean
value, (0 or 1), by the line:
newopus = result ~= 'RESULT' & translate(result,'.',' ') ~< 5.1215
We can break it down to make it a bit more understandable this way:
result ~="RESULT" <- This will give true or false, (1 or 0).
So, if the command worked, (dopus
version), then RESULT won't equal
'RESULT', so this is true, (1).
translate(result,'.',' ') <- Change v rrrr to v.rrrr, (eg. 5 1215 -> 5.1215).
~< 5.1215 <- Then compare the result to 5.1215.
If the version/revision information was not less than, (that is, greater
than, or equal to), 5.1215 then this part will also be true, (1).
The final part is just the boolean addition of the two results of these
two separate expressions. If both are true, then you have the following:
newopus = 1 & 1
If you had an early version of Opus then:
newopus = 1 & 0
It's just an easier way of making comparisons later in the script, you
won't need to do:
if versioninfo = '5 1215' then....
or similar.
|